<template>
  <div class='columninfom'>
    <div class="content-wrap my-search">
      <el-form :model="queryParams" size="mini" ref="queryForm" :inline="true">
        <el-form-item label="栏目名称">
          <el-input v-model="queryParams.name" placeholder="请输入" clearable size="small" @keyup.enter.native="handleQuery" />
        </el-form-item>
        <el-form-item>
          <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
          <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
        </el-form-item>
      </el-form>
    </div>
    <el-table :data="tableData">
      <el-table-column type="index" label="序号" width="50">
      </el-table-column>
      <el-table-column prop="name" label="栏目名称" show-overflow-tooltip align="center">
      </el-table-column>
      <el-table-column prop="operator" label="删除人员" width="200" align="center">
      </el-table-column>
      <el-table-column prop="deletedDate" label="删除时间" width="200" align="center">
      </el-table-column>
      <el-table-column label="操作" width="200" align="center">
        <template slot-scope="scope">
          <el-button @click="handlePreview( scope.row)" type="text" size="small" v-if="siteRow">浏览</el-button>
          <el-button @click="handleRecy( scope.row)" type="text" size="small" v-hasPermi="['system:recycle:update']">还原</el-button>
          <el-button @click="handleDel( scope.row)" type="text" size="small" v-hasPermi="['system:recycle:remove']">彻底删除</el-button>
        </template>
      </el-table-column>
    </el-table>


    <pagination v-show="total>0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize" @pagination="getList" />
  </div>
</template>

<script>
//栏目接口调用,栏目删除调用
import {
  getRecycleColumn,
  delRecycleColumn,
  recycleRecycleColumn,
} from "@/api/content/recyclingStation";
import { makeChannelViewUrl } from "@/api/content/clounm";
//---------------------------
export default {
  props: {
    siteRow: Object,
  },
  data() {
    return {
      radio: "1",
      tableData: [],
      total: 0,
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        name: undefined,
      },
      options: [{ value: "选项1", label: "栏目名称" }],
      value: "",
      //回收站栏目信息接口方法名称
      recycleColumn: {},
    };
  },

  components: {},

  computed: {},

  mounted() {
    //读取表格数据
    this.getList();
  },

  methods: {
    //浏览回收站栏目信息
    handlePreview(row) {
      makeChannelViewUrl({
        // siteAlias: this.siteRow?.alias || 0,
        channelId: row.channelId,
      }).then((res) => {
        let href = res.msg;
        window.open(href, "_blank");
      });
    },

    //还原回收站栏目信息
    handleRecy(row) {
      this.$confirm("此操作将还原该文件, 是否继续?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(() => {
          recycleRecycleColumn({ channelId: row.channelId }).then((res) => {
            if (res.code == 200) {
              this.getList();
            }
          });
          this.msgSuccess("还原成功");
        })
        .catch(() => {
          this.msgSuccess("已取消还原");
        });
    },

    //删除回收站栏目信息
    handleDel(row) {
      this.$confirm("此操作将彻底删除该文件, 是否继续?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(() => {
          delRecycleColumn({ channelId: row.channelId }).then((res) => {
            if (res.code == 200) {
              this.getList();
            }
          });
          this.msgSuccess("删除成功");
        })
        .catch(() => {
          this.msgSuccess("已取消删除");
        });
    },

    //读取回收站栏目信息
    getList() {
      this.queryParams.siteId = this.siteRow?.siteId || 0;
      getRecycleColumn(this.queryParams).then((res) => {
        this.tableData = res.data.list;
        this.total = res.data.totalCount;
      });
    },

    handleSizeChange(val) {},
    handleCurrentChange(val) {},
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
  },
};
</script>

<style scoped lang='scss'>
.columninfom {
  .el-select {
    margin: 0 15px 0 0;
  }
  height: 100%;
  .el-table {
    width: 100%;
  }
}
</style>